@echo off  
CHCP 65001
setlocal

setlocal enabledelayedexpansion

if "%~1"=="" call:print_help
if "%~2"=="" call:print_help
if "%~3"=="" call:print_help
if "%~4"=="" call:print_help
if "%~5"=="" call:print_help
if "%~6"=="" call:print_help


cd /d %~dp0


set PSCPEXE=pscp.exe
set USERNAME=%1
set HOSTLOCAL=%2
set PASSWORD=%3
set PATHNAME=%4
set LCOALPATH=%5
set FILENAME=%6


set tmp=tmp.txt
set md5file=binmd5.txt
set srcmd5=src.txt
REM md5

%PSCPEXE% -pw %PASSWORD%  %USERNAME%@%HOSTLOCAL%:%PATHNAME%/%md5file% %LCOALPATH%\%tmp%

set /P SRC=<%LCOALPATH%\src.txt
set /P DST=<%LCOALPATH%\tmp.txt

set src_md5=%SRC:~-0,32%
set src_dst=%DST:~-0,32%

if  %src_md5% ==  %src_dst% ( goto DELETE ) else (goto DOWN_BIN)

:DOWN_BIN
%PSCPEXE% -pw %PASSWORD%  %USERNAME%@%HOSTLOCAL%:%PATHNAME%/%FILENAME% %LCOALPATH%\%FILENAME%
goto MVNAME

:MVNAME
xcopy /y %LCOALPATH%\tmp.txt %LCOALPATH%\src.txt
goto DELETE

:DELETE
del  %LCOALPATH%\tmp.txt 

:success
echo success
goto end

goto :eof
set HOST=10.0.0.18
set USER=killer
set PASS=killer
set SRC_PATH=/home/killer/bin
set filename=server

:print_help
echo host user pass filename
e.g. 10.0.0.18 killer killer /home/killer/bin  server
goto end

:end
pause
 